package com.probiz.estore.system.dao.impl;

import java.util.List;

import com.probiz.estore.Constants;
import com.probiz.estore.common.model.system.Carrier;
import com.probiz.estore.core.dao.impl.HibernateGenericDaoImpl;
import com.probiz.estore.core.model.BaseObject;
import com.probiz.estore.system.dao.CarrierDao;


public class CarrierDaoImpl extends HibernateGenericDaoImpl<Carrier> implements CarrierDao {
	@Override
	protected void initFilterHqlMap() {
		filterHqlMap.put(BaseObject.FilterHqlName.DEFAULT, "select s from Carrier s where s.deleted !=1 order by s.carrierId desc");
	}
	/*
	 * (non-Javadoc)
	 * @see com.probiz.estore.system.dao.CarrierDao#getCarrierForEai()
	 */
	public Carrier getCarrierForEai() {
		List<Carrier> clist = this.findByHql("select i from Carrier i where i.carrierName='运输公司(U8导入数据用)'");
		if(clist!=null&&clist.size()>0){
			return clist.get(0);
		}else{
			Carrier carrier=new Carrier();
			carrier.setCarrierName("运输公司(U8导入数据用)");
			carrier.setDeleted(new Short("0"));
			carrier.setStatus(Constants.STATUS_ACTIVE);
			this.save(carrier);
			return carrier;
		}
		
	}
	/*
	 * (non-Javadoc)
	 * @see com.probiz.estore.system.dao.CarrierDao#findActiveCarriers()
	 */
	public List<Carrier> findActiveCarriers() {
		String propertyName = "status";
		return this.listByProperty(propertyName, Constants.STATUS_ACTIVE);
	}
}